import { httpClient } from '@/service/net/http-client'
import type { DrawParams, DrawResult } from '../types'

class ServerApi implements Api {
  async createUser(uid: string, idToken: string): Promise<string> {
    const config = {
      headers: { UID: uid, 'Id-Token': idToken }
    }
    return httpClient.Post<string>('/users', undefined, config)
  }
  /**
   * 发起渲染
   */
  performDraw(data: DrawParams) {
    return httpClient.Post<DrawResult>('/spell/draw/v2', data)
  }

  /**
   * 查询渲染进度
   * @param drawId 渲染任务 ID
   */
  queryDrawProcess(drawId: string) {
    const params = { draw_request_id: drawId }
    return httpClient.Get<DrawResult>('/draw/process/v2', { params })
  }
}

export const api: ServerApi = new ServerApi()
